<!DOCTYPE html>
<html>

<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

 
<title></title>

<link rel="shortcut icon" href="favicon.ico">
<link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
<link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="css/plugins/bootstrap-table/bootstrap-table.min.css"
	rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css?v=4.1.0" rel="stylesheet">


</head>

<body class="gray-bg">

	<div class="modal inmodal fade" id="myModal5" tabindex="-1"
		role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<small class="font-bold">新增员工
				</div>
				<div class="modal-body">
					<form id="myform">
						<div>
							<label>角&nbsp;&nbsp;色&nbsp;&nbsp;&nbsp;名&nbsp;&nbsp;称：</label><input type="text" name="name" />
						</div>
						<div>
							<label>角&nbsp;&nbsp;色&nbsp;&nbsp;&nbsp;&nbsp;类&nbsp;&nbsp;型：</label><input type="text" name="type" />
						</div>
						<div>
							<label>操作：</label><input type="text" name="type" />
						</div>
						<div>
							<label>身&nbsp;&nbsp;份&nbsp;&nbsp;证&nbsp;&nbsp;号：</label><input type="text" name="tabTime" />
						</div>
					</form>
				</div>

				<div class="modal-footer">
					<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" id="saveButton">保存</button>
				</div>
			</div>
		</div>
	</div>

	<div class="wrapper wrapper-content animated fadeInRight">

		<!-- Panel Other -->
		<div class="ibox float-e-margins">
			<div class="ibox-title">
				<button value="新增" style="width: 60px; height: 30px"
					data-toggle="modal" data-target="#myModal5">新增</button>
				<div class="ibox-tools"></div>
			</div>
			<div class="ibox-content">
				<div class="row row-lg">
					<div class="col-sm-12">
						<!-- Example Card View -->
						<div class="example-wrap">

							<div class="example">
								<table id="myTable">

								</table>
							</div>
						</div>
						<!-- End Example Card View -->
					</div>

				</div>
			</div>
		</div>
		<!-- End Panel Other -->

	</div>

	<!-- 全局js -->
	<script src="js/jquery.min.js?v=2.1.4"></script>
	<script src="js/bootstrap.min.js?v=3.3.6"></script>

	<!-- 自定义js -->
	<script src="js/content.js?v=1.0.0"></script>


	<!-- Bootstrap table -->
	<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
	<script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
	<script
		src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="js/aivms5.js"></script>

	<script>
	var base_url = aivms5_base_url;
 	$("#myTable").bootstrapTable({
        url: admin_url + "/adminRoleMenu/list",
        method:'post',
        cache:false,
        pagination:true,
        sortable:false,
        sidePagination:"server",
        pageNumber:1,
        pageSize:10,
        search:false,
        uniqueId:'id',
        showRefresh: false,
        queryParams: queryParams,//传递参数（*）
		contentType: "application/x-www-form-urlencoded",
		ajaxOptions:{
          headers: {"token":"aaaa"}
        },
        clickToSelect:true,
        columns:[
			{  
			    formatter: function (value, row, index) {  
			        return index+1;  
			    }  
			},
			{
                field:"checked",
                checkbox : true
            },
            {
                field:"name",
                title:"角色名称"
            },
			{
                field:"type",
                title:"角色类型"
            },
			{
                field:"tabTime",
                title:"操作"
            },
            {
                field:"uploadTime",
                title:"身份证号"
            },
         
          
        
        ]
    });

	  function queryParams(params) {
        var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            limit: params.limit,   //页面大小
            offset: params.offset,  //页码
           
        };
        return temp;
       };
       
       
       $.ajax({
			type : "POST",
			url :  aivms5_control_url + "/personGroup/list",
			success : function(data) {

					var value = "";
					for (var i = 0; i < data.length; i++) {
						var obj = data[i];
						value += "<option value='"+obj.groupIdentifier+"'>"+ obj.groupName + "</option>"
					}
					$("#groupidentifier").append(value);
			},
			error : function(data) {
				alert(data);
			}
		});
       
       $("#saveButton").click(function(){
           
          	var params = $("#myform").serialize();
          	var groupname = $("#groupidentifier").find("option:selected").text();
          	params += "&groupname="+groupname;
                  $.ajax( {  
                      type : "POST",  
                      url : base_url+ "/member/addOrUpdate",  
                      data : params,  
                      success : function(data) {  
                      	if(data.code == 1000)
                      	{ 
                      		$("#myModal5").modal("hide");
                      		$("#myTable").bootstrapTable('refresh');
                      	}
                      	else
                      	{
                      		alert(data.msg)
                      	}
                      },
                      error: function(XMLHttpRequest, textStatus, errorThrown) {
                          alert(XMLHttpRequest.status);
                          alert(XMLHttpRequest.readyState);
                          alert(textStatus);
                      }
                  });  
          })//   
</script>

</body>

</html>
